home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / lattice / _umulsi3.s < prev    next >
Text File  |  1992-06-15  |  744b  |  38 lines

  1. ; unsigned long integer multiplication routine
  2. ;
  3. ; written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  4. ;
  5. ;
  6. ; Revision 1.1, kub 03-90
  7. ; first version, replaces the appropriate routine from fixnum.s.
  8. ; This one is short and fast for the common case of both longs <= 0x0000ffff,
  9. ; but the case of a zero lowword is no longer recognized.
  10. ; (besides it's easier to read this source 8-)
  11.  
  12.     text
  13.     even
  14.     xdef    __CXM33
  15.  
  16. __CXM33:
  17.     movem.l    d2-d3,-(sp)
  18.     move.l    d1,d2
  19.     move.l    d1,d3
  20.     swap    d2
  21.     move.l    d0,d1
  22.     swap    d0
  23.     
  24.     ext.l    d0        ; u.h <> 0 ?
  25.     beq.s    1$
  26.     mulu.w    d3,d0        ; r  = v.l * u.h
  27. 1$    tst.w    d2        ; v.h <> 0 ?
  28.     beq.s    2$
  29.     mulu.w    d1,d2        ; r += v.h * u.l
  30.     add.w    d2,d0
  31. 2$    swap    d0
  32.     clr.w    d0
  33.     mulu.w    d3,d1        ; r += v.l * u.l
  34.     add.l    d1,d0
  35.     movem.l    (sp)+,d2-d3
  36.     rts
  37.     end
  38.